package com.itheima.Zixi4.ZuoYe.Zuoye3;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Zuoye3 {
    public static void main(String[] args) {
        Map<Laomo,String> map  = new TreeMap<>();
        map.put(new Laomo("张三",18),"北京");
        map.put(new Laomo("李四",23),"上海");
        map.put(new Laomo("王五",17),"广州");
        map.put(new Laomo("赵六",21),"深圳");
        map.put(new Laomo("田七",18),"杭州");
        map.forEach((k,v)-> System.out.println(k+"--"+v));
        System.out.println("------------------");
        map.remove(new Laomo("张三",18));
        Set <Laomo> keys =map.keySet();
        for(Laomo key:keys){
            System.out.println(key+"--"+map.get(key));
        }
        System.out.println("------------------");
        map.put(new Laomo("李四",23),"郑州" );
        Set <Map.Entry<Laomo, String>> entrySet =map.entrySet();
        for(Map.Entry<Laomo, String> entry:entrySet){
            System.out.println(entry.getKey()+"--"+entry.getValue());
        }
        System.out.println("------------------");

    }
}
